package ch.selise.exercise.pattern.notepad.command.impl;

import java.util.Scanner;

import ch.selise.exercise.pattern.notepad.command.BaseCommand;
import ch.selise.exercise.pattern.notepad.storage.AppStorageSingleton;

public class DeleteCommand extends BaseCommand // implements IUndoableCommand
{

	String textDeleted;

	public DeleteCommand(int index) {
		super.setIndex(index);
	}

	public DeleteCommand(Scanner in) {
		int index = Integer.parseInt(in.nextLine());
		super.setIndex(index);
	}

	@Override
	public void execute() {
		textDeleted = AppStorageSingleton.getInstance().getText()
				.get(super.getIndex());
		AppStorageSingleton.getInstance().getText().remove(super.getIndex());

		//AppStorageSingleton.getInstance().addCommand(this);
	}

	@Override
	public void undoCommand() {
		AppStorageSingleton.getInstance().getText()
				.add(super.getIndex(), textDeleted);

	}

	/*
	 * @Override public void redoCommand() { this.execute();
	 * 
	 * }
	 */

}
